package net.myspring.middle.mapper;

import net.myspring.common.mybatis.domain.Page;
import net.myspring.common.mybatis.domain.Pageable;
import net.myspring.common.mybatis.provider.mapper.CrudMapper;
import net.myspring.middle.domain.Department;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;
import java.util.Map;

/**
 * Created by liuj on 16/7/10.
 */
@Mapper
public interface DepartmentMapper extends CrudMapper<Department,String> {

    Page<Department> findPage(Pageable pageable, @Param("p") Map<String, Object> map);

    List<Department> findAll();

    List<Department> findByParentId(String parentId);

    Department findByName(String name);

    @Cacheable(value = "departments", key = "#p0")
    Department findOne(String id);

    @CacheEvict(value = "departments", key = "#p0.id")
    int update(Department department);
}
